
import { useTranslation } from 'react-i18next'
import { Link, useNavigate } from "react-router-dom";
import HeaderTitle from "../login/header";
import style from "./index.module.less"
import { EyeInvisibleOutline, EyeOutline } from "antd-mobile-icons"
import React, { Fragment, useState ,useEffect} from 'react'
import {
	Form,
	Input,
	Checkbox,
	Button,
	Toast,

} from 'antd-mobile'
import { getactivitylist } from "@/apis/user.js"

import banner1 from "../../static/1.jpg"
import banner2 from "../../static/2.jpg"
import banner3 from "../../static/3.jpg"
import banner4 from "../../static/4.jpg"

const Promotionlist = (props) => {
	const BASE_URL = import.meta.env.VITE_BASE_URL;
	const [flag, setFlag] = useState(false);
	const [activitylist,setActivitylist] = useState([]);
	const navigate = useNavigate()
	useEffect(() => {
		console.log("初始化----优惠活动");
		// setFlag(true);
		getactivitylist().then(res => {
		
			if (res.status.errorCode == 0) {
				setActivitylist(res.data.data)
	
			}
		})
		setTimeout(()=>{
			if (window.scrollTo) {
				window.scrollTo(0, 0);
			} else if (document.body.scrollTop) {
				document.body.scrollTop = 0;
			} else {
				document.documentElement.scrollTop = 0;
			}
			document.getElementById('root').scrollIntoView(true);
			document.getElementById('body').scrollIntoView(true);
		},0)
		return ()=>{console.log('初始化----个人中心')}
	  }, []);
	  console.log(activitylist)
	  const { t } = useTranslation();
	return (
		<React.Fragment>
			<HeaderTitle title={t('mine.title15')} right_title={t('agent.title2')}/>
			<div className={style['main']}>
				<div className={style['content']}>
				{activitylist.length > 0 && (
					activitylist.map((item,index)=>{
					return (
						<div className={style['am-list']} onClick={() => navigate('/newsdetail/'+item.id)} key={index}>
						<div className={style['am-list-body']}>
							<div className={style['bodycon']}>
							<img className={style['banimg']} src={item.title_img} alt="" />
							{item.title}
							</div>
						</div>
						</div>
					);
					})
				)}
				</div>
			</div>
		</React.Fragment>
	)
}


export default Promotionlist
